package com.deep.test

import org.apache.spark.mllib.linalg.Vectors
import org.apache.spark.{SparkConf, SparkContext}
import org.apache.spark.mllib.stat.Statistics
import org.apache.log4j.{ Level, Logger }

/**
 * @author sw
 * @create 2023-05-29 15:56
 */
object Test02 {
  Logger.getRootLogger.setLevel(Level.WARN)


  def main(args: Array[String]): Unit = {
    val conf = new SparkConf().setMaster("local").setAppName("ALS")
    val sc = new SparkContext(conf)
    sc.setLogLevel("WARN")
    var data_path = "data/sample_stat.txt"
    var data = sc.textFile(data_path)
      .map(_.split("\t"))
      .map(f => f.map(f => f.toDouble))
    var data1 = data.map(f => Vectors.dense(f))
    var stat1 = Statistics.colStats(data1)
    println(stat1.max)
    println(stat1.min)
    println(stat1.mean)
    println(stat1.variance)
    println(stat1.normL1)
    println(stat1.normL2)

  }
}
